import type { Address } from '@/types/address'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义 Store,用于管理收获地址
export const useAddressStore = defineStore('address', () => {
  // 收获地址信息
  const selectedAddress = ref<Address>()

  // 定义用于修改登录用户的默认收货地址
  const changeSelectedAddress = (val: Address) => {
    selectedAddress.value = val
  }

  // 记得 return
  return {
    selectedAddress,
    changeSelectedAddress,
  }
})
